package app.itgungnir.compose.wan.business.main.square

import androidx.lifecycle.ViewModel
import app.itgungnir.compose.wan.WanApp
import app.itgungnir.compose.wan.utils.*
import kotlinx.coroutines.flow.map

class SquareViewModel : ViewModel() {

    val hasLoginFlow = WanApp.instance.dataStore.data.map { it.hasLogin }
    val userInfoFlow = WanApp.instance.dataStore.data.map { it.userInfo }

    val squareDataFlow = pagingSourceWithoutCache(firstPageIndex = 1, pageSize = 20) {
        wanAndroidService.getSquareList(it).wanResponse<WanPagingResponse<Square>>()
    }
}
